﻿using HamcoWcs.Models.Common;
using HamcoWcs.Models.Common.Enums;
using System;
using System.Collections.Generic;

namespace HamcoWcs.Models.ForeEndModels.UITasks
{
    public class QueryTargetPalletModel
    {
        public string? Size { get; set; }
        public string? Type { get; set; }
    }

    public class SrmCycleTaskModel
    {
        public string UnitId { get; set; }
        public string SrcLoc { get; set; }
        public string DesLoc { get; set; }
    }

    public class ChangeBufferDestinationModel
    {
        public string MachineName { get; set; }
        public string PortName { get; set; }
        public string UnitId { get; set; }
        public string NewDestination { get; set; }
    }

    public class QueryMainTask : PageSizeTime
    {
        public string Sender { get; set; }
        public string TaskId { get; set; }
        public string UnitId { get; set; }
        public string SrcMachine { get; set; }
        public string DesMachine { get; set; }

    }

    public class QueryMainTaskHistoryModel : QueryMainTask
    {
        [VuageQuery(EnumVuageQueryType.Ignore)]
        public string RoutePath { get; set; }

    }


    public class UIMainTask
    {

        public long Id { get; set; }
        public string Sender { get; set; }
        public string UnitId { get; set; }
        public string TaskId { get; set; }
        public string SrcMachine { get; set; }
        public string SrcPosition { get; set; }
        public string SrcType { get; set; }
        public string SrcZone { get; set; }
        public string DesMachine { get; set; }
        public string DesPosition { get; set; }
        public string DesType { get; set; }
        public string DesZone { get; set; }
        public string OldDesMachine { get; set; }
        public string OldDesPosition { get; set; }
        public string OldDesType { get; set; }
        public string OldDesZone { get; set; }
        public string CurrentMachine { get; set; }
        public string CurrentPosition { get; set; }
        public string CurrentType { get; set; }
        public string CurrentZone { get; set; }
        public int SrcPriority { get; set; } = 1;
        public int DesPriority { get; set; } = 1;
        //public int IsHandOff { get; set; } = 0;

        public string CreatedTime { get; set; }
        public string StartTime { get; set; }
        public string CompleteTime { get; set; }
        public string TransportTime
        {
            get
            {
            
                try
                {
                    var a1 = DateTime.TryParse(CompleteTime, out DateTime e);
                    var a2 = DateTime.TryParse(StartTime, out DateTime s);

                    if (e == default(DateTime))
                    {
                        return "";
                    }
                    if (a1 && a2)
                    {
                        var t = (e - s);
                        return t.GetDuration();
                    }
                    return "";

                }
                catch (Exception)
                {
                    return "";
                }
               
            }
        }



        //public int IsReportStart { get; set; }
        public int IsTimeout { get; set; }
        //public string TransactionId { get; set; }
        public string Path { get; set; }
        //public string MaterialInfo { get; set; }
        //public string InventoryInfo { get; set; }
        //public string FromLoc { get; set; }
        //public string ToLoc { get; set; }
        public string Priority { get; set; }
        //public string Extend { get; set; }
        //public string ReasonCode { get; set; }
        public string MainTaskType { get; set; }
        public int ActiveSubTaskId { get; set; }
        public int TotalSubTaskNum { get; set; }
        public string TaskStatus { get; set; }
        public List<UISubTask> SubTasks { get; set; } = new List<UISubTask>();

    }


    public class MainTaskCreate
    {
        public string TaskType { get; set; }
        public string FromLoc { get; set; }
        public string ToLoc { get; set; }
        public string UnitId { get; set; }
    }

    public class OutboundCreateModel
    {
        public string FromLoc { get; set; }
        public string ToLoc { get; set; }
        public string UnitId { get; set; }
    }

    public class InventoryTaskInfo
    {
        /// <summary>
        /// 1：指定货架 2：指定Srm 3:全区域
        /// </summary>
        public EnumInventoryMode Mode { get; set; }
        public string[] Shelves { get; set; }
        public string TargetSrm { get; set; }
    }

    //public class InventoryShelf
    //{
    //    public EnumInventoryMode Mode { get; set; }
    //    public string[] Shelves { get; set; }
    //}

    public class MainTaskChangePriorityDto : BaseModel
    {
        public string Priority { get; set; }
        public string UnitId { get; set; }
    }

    public class ChangePPKTaskModel
    {
        public string TaskId { get; set; }
        public string NewDesMachine { get; set; }
    }

    public class SrmTaskQueryModel
    {
        public string SrmName { get; set; }
    }

    public class UIUpdateSubtask
    {
        public int taskId { get; set; }
        public string unitId { get; set; }
        public EnumSubTaskStatus TaskStatus { get; set; }
    }

    public class UISrmSubTask : BaseModel
    {
        public string TaskFrom { get; set; }

        public string UnitId { get; set; }

        public string FromLoc { get; set; }

        public string ToLoc { get; set; }

        public string PlcName { get; set; }
        public string TaskStatus { get; set; }
    }


}
